package com.hand.springcloud.service;


import com.hand.springcloud.entities.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * @ Description   :  feign
 * @ Author        :  xiong.yilin@hand-china.com
 * @ CreateDate    :  2019/9/9 12:02
 */
// 只要在已存在的 ProductClientService 接口上的 @FeignClient 注解中，加上 fallback 指定熔断处
// 理类即可： ProductClientServiceFallBack.class
// 指定调用的服务 MICROSERVICE-PRODUCT
@FeignClient(value="microservice-product",fallback = ProductClientServiceFallBack.class)
public interface ProductClientService {

    @RequestMapping(value=  "/product/get/{id}",method = RequestMethod.GET)
    Product get(@PathVariable("id") Long id);

    @RequestMapping(value = "/product/list",method = RequestMethod.GET)
    List<Product> list();

    @RequestMapping(value = "/product/add",method = RequestMethod.POST)
    boolean add(Product product);
}
